package Work1;
import java.util.Random;
import java.util.Scanner;

public class demo2 {
	public static void main(String[] args) {
	Random rd = new Random();
	Scanner sc = new Scanner(System.in);
	int result = rd.nextInt(100);
	int guess;
	int x=0;
	System.out.println("你的猜测是：");
	guess = sc.nextInt();
	while(guess != result) {
		if(guess>result) {
			System.out.println("大了!");
			x++;
			guess = sc.nextInt();
		}else if (guess<result) {
			System.out.println("小了!");
			
			x++;
			guess = sc.nextInt();
		}
	}
	System.out.println("猜对了"+result+",共猜测了"+(x+1)+"次");
	}
}
